﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.Space.QueryEngine
{
    /// <summary>
    /// This class represents an greater than query for a space container.
    /// </summary>
    [Serializable]
    public class GreaterThan : AbstractSpaceQuery
    {
        /// <summary>
        /// The compare value.
        /// </summary>
        private ISpaceEntry value;

        /// <summary>
        /// Initializes a new instance of the <see cref="GreaterThan"/> class.
        /// </summary>
        /// <param name="value">The compare value.</param>
        public GreaterThan(ISpaceEntry value)
            : base()
        {
            this.value = value;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="GreaterThan"/> class.
        /// </summary>
        /// <param name="value">The compare value.</param>
        /// <param name="status">The object status criteria.</param>
        public GreaterThan(ISpaceEntry value, SpaceObjectStatus status)
            : base(status)
        {
            this.value = value;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="GreaterThan"/> class.
        /// </summary>
        /// <param name="value">The compare value.</param>
        /// <param name="limit">The maximum number of query results.</param>
        public GreaterThan(ISpaceEntry value, int limit)
            : base(limit)
        {
            this.value = value;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="GreaterThan"/> class.
        /// </summary>
        /// <param name="value">The compare value.</param>
        /// <param name="limit">The maximum number of query results.</param>
        /// <param name="status">The object status criteria.</param>
        public GreaterThan(ISpaceEntry value, int limit, SpaceObjectStatus status)
            : base(limit, status)
        {
            this.value = value;
        }

        /// <summary>
        /// Gets or sets the compare value.
        /// </summary>
        /// <value>The compare value</value>
        public ISpaceEntry Value
        {
            get { return this.value; }
            set { this.value = value; }
        }

        /// <summary>
        /// Defines the query criteria of the specified query.
        /// </summary>
        /// <param name="item">The query source items.</param>
        /// <returns>
        /// The space ID fulfills the query criteria the method returns true otherwise, false.
        /// </returns>
        public override bool QueryDefinition(ISpaceEntry item)
        {
            return item.GreaterThan(this.value);
        }
    }
}